//
//  LabelAreaSelectCell.m
//  OrderSys
//
//  Created by JM on 15/10/12.
//  Copyright © 2015年 zjlskj. All rights reserved.
//

#import "LabelAreaSelectCell.h"
#import "AddressChoicePickerView.h"
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;
@interface LabelAreaSelectCell ()
@property(nonatomic, retain)NSString *forOutStirng;
@end

@implementation LabelAreaSelectCell

- (void)awakeFromNib {
    // Initialization code
}
+ (instancetype)cell {
    
    LabelAreaSelectCell *cell =  [[LabelAreaSelectCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LabelAreaSelectCell"];
    cell.leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 90, 40)];
    cell.leftLabel.backgroundColor = [UIColor clearColor];
    cell.leftLabel.font = [UIFont systemFontOfSize:16];
    cell.leftLabel.tag = 1;
    [cell.contentView addSubview:cell.leftLabel];
    
    cell.rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 5, 200, 30)];
    cell.rightLabel.backgroundColor = [UIColor clearColor];
    cell.rightLabel.font = [UIFont systemFontOfSize:16];
    cell.rightLabel.tag = 2;
    [cell.contentView addSubview:cell.rightLabel];
    cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"圆箭头-50x50向下.png"]];
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
- (NSString *)valueData {
    return self.forOutStirng;
}

- (void)didSelect {
    WS(weakSelf);
    AddressChoicePickerView *addressPickerView = [[AddressChoicePickerView alloc]init];
    addressPickerView.block = ^(AddressChoicePickerView *view,UIButton *btn,AreaObject *locate){
        weakSelf.forOutStirng = [NSString stringWithFormat:@"%@",locate];
        weakSelf.rightLabel.text = weakSelf.forOutStirng;
    };
    [addressPickerView show];
}

- (void)didSeletedDateStr:(NSString *)aStrDate {
    self.rightLabel.text = aStrDate;
}

+ (LabelAreaSelectCell *)cellWithLabel:(NSString *)labelText tableView:(UITableView *) tableView {
    
    LabelAreaSelectCell * cell = [LabelAreaSelectCell cell];
    cell.leftLabel.text = labelText;
    cell.tableView = tableView;
    return cell;
}@end
